<!DOCTYPE HTML>
<html>
<head>
    <title>方案管理</title>
    <th:block th:replace="common::common_css" />
    <th:block th:replace="common::common_js" />
    <th:block th:replace="common::global_js" />
    <script>
        window.onload = function (){
            alert(basePath)
        }
        $(function () {
            $('#managerTab').datagrid({
                columns: [
                    [
                        {field: 'entId', title: 'entId', checkbox: true},
                        {field: 'ruleId', title: '规则id', hidden: true},
                        {field: 'projID', title: '项目id', hidden: true},
                        {field: 'projectPackageID', title: '父项目id', hidden: true},
                        {field: 'ruleName', title: '规则名称', width: 200},
                        {field: 'procedureName', title: '存储过程名称', width: 300},
                        {field: 'entType', title: '类型', width: 150},
                        {
                            field: 'checkContext', title: '检查内容', width: 300,
                            formatter: function (value) {
                                if (value) {
                                    value = "<span title='" + value + "'>" + value + "</span>"
                                }
                                return value;
                            }
                        }
                    ]
                ],
                toolbar: '#tb'

            });
            var p1 = $('#managerTab').datagrid().datagrid('getPager');
            $(p1).pagination({
                pageSize: 10,//每页显示的记录条数，默认为10
                pageList: [10, 20, 30],//可以设置每页记录条数的列表
                beforePageText: '第',//页数文本框前显示的汉字
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
            });


            $('#procedureName').searchbox({
                prompt: '请选择存储过程',
                //readonly:true,
                required: true,
                searcher: function (value, name) {
                    openProcedureSelWin();
                }
            });

            //质检项目tree
            buildQualityTree();
        });


        //获取质检项目目录树
        function buildQualityTree() {
            $("#treeDemo").tree({
                url: basePath + "/zj/zjProcedureManager.do?method=buildQualityTree&newDate=" + (new Date()).getTime(),
                animate: true,//定义当节点展开折叠时是否显示动画效果
                onContextMenu: function (e, node) {
                    e.preventDefault();
                    $(this).tree('select', node.target);
                    if (node.id != "0") {
                        var parentNode = $(this).tree('getParent', node.target);
                        if (parentNode.id != "0") {
                            if (node.attributes.isParent) {
                                $("#pMenu1").menu('show', {
                                    left: e.pageX,
                                    top: e.pageY
                                });
                            } else {
                                $("#lMenu").menu('show', {
                                    left: e.pageX,
                                    top: e.pageY
                                });
                            }
                        } else {
                            $("#pMenu1").menu('show', {
                                left: e.pageX,
                                top: e.pageY
                            });
                        }
                    } else {
                        $("#pMenu3").menu('show', {
                            left: e.pageX,
                            top: e.pageY
                        });
                    }
                },
                onLoadSuccess: function () {
                    //关闭遮罩
                    $('#loading-mask').fadeOut();
                },
                onBeforeExpand: function (node) {
                    var isParent = node.attributes.isParent;
                    if (isParent) {
                        var childrenNode = $("#treeDemo").tree('getChildren', node.target);
                        if (childrenNode.length === 0) {//当前节点下没有子节点时,不展开
                            return false;
                        }
                    }
                },
                onClick: function (node) {
                    var isParent = node.attributes.isParent;
                    if (isParent) {
                        $("#treeDemo").tree('toggle', node.target);
                    } else {//叶子节点（展现该质检项目下的质检规则）
                        var parentNode = $(this).tree('getParent', node.target);
                        initRuleGrid(node.id, parentNode.id);
                    }
                },
                onBeforeEdit: function (node) {
                    beforeNodeText = node.text;
                },
                onAfterEdit: function (node) {
                    if (null == node.text || node.text.length == 0) {
                        $.messager.alert('消息提示', '节点名称不能为空!');
                        setTimeout(function () {
                            $(this).tree('beginEdit', node.target);
                        }, 10);
                    } else {
                        var flag = "update";
                        if (beforeNodeText == node.text) {
                            return;
                        }
                        saveOrUpdateNode(node, node.text, flag);
                    }
                },
                onLoadError: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus);
                    return false;
                }
            });
        }

        function initRuleGrid(prjId, projectPackageID) {
            if (!prjId) {
                prjId = "";
            }
            //var paramData = "{prjId:'" + prjId+"'}";
            $("#managerTab").datagrid('loadData', {total: 0, rows: []});
            $("#managerTab").datagrid({
                queryParams: {},
                url: basePath + "/zj/zjProcedureManager.do?method=getRuleInfo&prjId=" + prjId + "&projectPackageID=" + projectPackageID + "&newDate=" + (new Date()).getTime()
            });
        }

        function addProjectPkg() {
            var node = $("#treeDemo").tree('getSelected');//获取选中的节点
            if (null != node) {
                $.messager.confirm("消息提示", "确认新建质检项目目录吗？", function (r) {
                    if (r) {
                        var id = 100 + newCount;
                        var param = {
                            parent: node ? node.target : null,
                            data: [{
                                id: id,
                                state: 'closed',
                                text: "新建目录" + (newCount++),
                                attributes: {'isParent': true}
                            }]
                        };
                        $("#treeDemo").tree('append', param);
                        var newNode = $("#treeDemo").tree('find', id);
                        saveOrUpdateNode(newNode, newNode.text, 'save');
                    }
                });
            }
        }


        //节点后面添加自定义按钮
        var newCount = 1;

        //新增或修改节点信息
        function saveOrUpdateNode(node, newName, flag) {
            var pId = "";
            if (node != null) {
                var parentNode = $("#treeDemo").tree('getParent', node.target);
                if (parentNode != null) {
                    pId = parentNode.id;
                }
            }
            $.ajax({
                type: "post",
                dataType: "json",
                url: basePath + "/zj/zjProcedureManager.do?method=saveOrUpdateNode&newDate=" + (new Date()).getTime(),
                async: true,
                success: function (responseData) {
                    var result = responseData.result;
                    if ('ok' == result) {
                        if ("save" == flag) {
                            node.id = responseData.prjId;
                            $("#treeDemo").tree('update', node);//修改节点ID
                            $("#treeDemo").tree('beginEdit', node.target);
                        }
                        return true;
                    } else if ('no' == result) {
                        alert("该名字已存在!");//待处理
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus);
                },
                data: {
                    appCode: 'XJYT',
                    nodeId: node.id,
                    nodeParentId: pId,
                    flag: flag,
                    nodeNewName: newName,
                    isParent: node.attributes.isParent
                }
            });
        }

        function addProject() {
            var node = $("#treeDemo").tree('getSelected');//获取选中的节点
            if (null != node) {
                $.messager.confirm("消息提示", "确认新建质检项目吗？", function (r) {
                    if (r) {
                        var id = 100 + newCount;
                        //var param={parent:node?node.target:null,data:[{id:id,state:'closed',text:"新建质检项目" + (newCount++),attributes:{'isParent':false}}]};
                        //$("#treeDemo").tree('append',param);
                        $("#treeDemo").tree('append', {
                            parent: node.target,
                            data: [{id: id, text: "新建质检项目" + (newCount++), attributes: {'isParent': false}}]
                        });
                        var newNode = $("#treeDemo").tree('find', id);
                        saveOrUpdateProject(newNode, newNode.text, 'save');
                    }
                });
            }
        }

        function saveOrUpdateProject(node, newName, flag) {
            var pId = "";
            if (node != null) {
                var parentNode = $("#treeDemo").tree('getParent', node.target);
                if (parentNode != null) {
                    pId = parentNode.id;
                }
            }
            $.ajax({
                type: "post",
                dataType: "json",
                url: basePath + "/zj/zjProcedureManager.do?method=saveOrUpdateProject&newDate=" + (new Date()).getTime(),
                async: true,
                success: function (responseData) {
                    var result = responseData.result;
                    if ('ok' == result) {
                        if ("save" == flag) {
                            node.id = responseData.prjId;
                            $("#treeDemo").tree('update', node);//修改节点ID
                            $("#treeDemo").tree('beginEdit', node.target);
                        }
                        return true;
                    } else if ('no' == result) {
                        alert("该名字已存在!");//待处理
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus);
                },
                data: {
                    appCode: 'XJYT',
                    nodeId: node.id,
                    nodeParentId: pId,
                    flag: flag,
                    nodeNewName: newName,
                    isParent: node.attributes.isParent
                }
            });
        }

        /*
        *删除选中的节点
        */
        function deleteProject() {
            var node = $("#treeDemo").tree('getSelected');//获取选中的节点
            var isParent = node.attributes.isParent;
            var parentNode = $("#treeDemo").tree('getParent', node.target);
            $.messager.confirm("消息提示", "确认删除 节点 【" + node.text + "】 吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "post",
                        url: basePath + "/zj/zjProcedureManager.do?method=deleteNode&newDate=" + (new Date()).getTime(),
                        async: true,
                        dataType: "json",
                        success: function (responseData) {
                            if (responseData.returnFlag) {
                                $("#treeDemo").tree('remove', node.target)
                                //当删除子节点后，父节点下若没有子节点，那么父节点会变为叶子节点。防止父节点变为叶子节点需手动设置
                                var childrenLength = $("#treeDemo").tree('getChildren', parentNode.target).length;
                                if (childrenLength == 0) {
                                    $("#treeDemo").tree('insert', {
                                        before: parentNode.target,
                                        data: [{
                                            id: parentNode.id,
                                            text: parentNode.text,
                                            state: 'closed',
                                            attributes: parentNode.attributes
                                        }]
                                    });
                                    $("#treeDemo").tree('remove', parentNode.target);
                                }
                                $.messager.alert('消息提示', '删除成功!');
                                return true;
                            } else {
                                $.messager.alert('消息提示', '删除失败!', 'error');
                                return false;
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus, 'error');
                            return false;
                        },
                        data: {nodeId: node.id, isParent: isParent}
                    });
                }
            });
        }

        function editProjectName() {
            var node = $("#treeDemo").tree('getSelected');
            $("#treeDemo").tree('beginEdit', node.target);
        }

        //删除规则
        function deleteRuleData() {
            var selectedRows = $('#managerTab').datagrid('getSelections');
            var ruleArray = new Array();//目标实体绑定array
            if (selectedRows.length == 0) {
                alert("请选择要删除的规则！")
                return;
            }
            for (i = 0; i < selectedRows.length; i++) {
                var rowData = {
                    'projectPackageID': selectedRows[i].projectPackageID,
                    'projID': selectedRows[i].projID,
                    'ruleId': selectedRows[i].ruleId
                };
                ruleArray.push(rowData);
            }

            var ruleArrayDataJson = arrayToJson(ruleArray);//规则参数设置
            var ruleJson = ruleArrayDataJson == "[]" ? " " : ruleArrayDataJson;
            $.messager.confirm("消息提示", "确认删除规则吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "post",
                        url: basePath + "/zj/zjProcedureManager.do?method=deleteRuleData&newDate=" + (new Date()).getTime(),
                        async: true,
                        dataType: "json",
                        success: function (responseData) {
                            var returnFlag = responseData.returnFlag;
                            var returnMessage = responseData.returnMessage;
                            if (returnFlag) {
                                $("#managerTab").datagrid("reload");
                                $.messager.alert('消息提示', "删除成功！");
                            } else {
                                $.messager.alert('消息提示', returnMessage);
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus);
                            return false;
                        },
                        data: {
                            ruleJson: ruleJson,
                            appCode: "XJYT"
                        }
                    });

                }
            })

        }

        //打开规程创建窗口
        function openAddQualityRuleWin() {
            $("#btn_FlowManage_cancel").unbind("click");
            $("#btn_FlowManage_cancel").bind("click", flowManageCancel);//取消
            $("#btn_FlowManage_sure").unbind("click");
            $("#btn_FlowManage_sure").bind("click", addQualityRuleSure);//确定
            $('#ruleManageWin').dialog({
                title: '存储过程规则定制',
                closed: false,
                buttons: '#div_FlowManage_Btns',
                inline: true
            });
            $("#procedureParamBindingGrid").datagrid({
                title: '存储过程参数绑定',
                width: 680,
                height: 250,
                striped: true,
                rownumbers: true,
                pagination: false,
                singleSelect: true,
                columns: [
                    [{
                        title: 'id',
                        field: 'id',
                        hidden: true
                    }, {
                        title: '参数名',
                        field: 'argument_name',
                        width: 180
                    }, {
                        title: '绑定值',
                        field: 'binding_param',
                        width: 150,
                        editor: {
                            type: 'combobox',
                            options: {
                                valueField: "value",
                                textField: "text"
                            }
                        }
                    }, {
                        title: '参数类型',
                        field: 'data_type',
                        width: 100
                    }, {
                        title: '输入输出类型',
                        field: 'in_out',
                        width: 100
                    }, {
                        title: '参数位置',
                        field: 'position',
                        //hidden : true,
                        width: 80
                    }]
                ],
                onClickRow: function (rowIndex, rowData) {
                    if (rowIndex != null && rowData.in_out == 'IN') {
                        $("#procedureParamBindingGrid").datagrid("beginEdit", rowIndex);
                        var ed = $('#procedureParamBindingGrid').datagrid('getEditor', {
                            index: rowIndex,
                            field: 'binding_param'
                        });
                        var qualityProjcetParamArray = [
                            {
                                text: '年月日',
                                value: 'P_DATE'
                            }, {
                                text: '年月',
                                value: 'P_NY'
                            }, {
                                text: '时间',
                                value: 'P_TIME'
                            }, {
                                text: '机构id',
                                value: 'P_ORGID'
                            }, {
                                text: '机构名称',
                                value: 'P_ORGNAME'
                            }, {
                                text: '方案id',
                                value: 'P_PROJECTID'
                            }, {
                                text: '规则id',
                                value: 'P_RULEID'
                            }, {
                                text: '选择机构',
                                value: 'P_SELECT_ORG'
                            }
                        ];
                        $(ed.target).combobox('loadData', qualityProjcetParamArray);
                        $(ed.target).combobox({
                            onHidePanel: function () {
                                $("#procedureParamBindingGrid").datagrid('endEdit', rowIndex);
                            }
                        });
                        if (rowData.binding_param) {
                            $(ed.target).combobox('setValue', rowData.binding_param);
                        }
                        lastSelect = rowIndex;
                    }
                }
            });
            $('#procedureParamBindingGrid').datagrid('loadData', {total: 0, rows: []});
            $('#ruleName').val("");
            $('#procedureName').searchbox('setValue', '');
        }

        function flowManageCancel() {
            $('#ruleManageWin').dialog({closed: true});
        }

        function addQualityRuleSure() {
            var node = $("#treeDemo").tree('getSelected');
            var projID = node.id;
            if (!projID) {
                $.messager.alert('消息提示', '请选择质检项目!');
                return;
            }
            var projectPackageId = "";
            if (node != null) {
                var parentNode = $("#treeDemo").tree('getParent', node.target);
                if (parentNode != null) {
                    projectPackageId = parentNode.id;
                }
            }
            var ruleName = $('#ruleName').val();// 规则名称
            var otType = $('#otType').val();
            var checkContext = $('#checkContext').val();
            if (!ruleName) {
                $.messager.alert('消息提示', '请输入规则名称!');
                return;
            }
            // var ruleId = $('#ruleId').val();// 规则名称
            var procedureName = $('#procedureName').searchbox('getValue');//过程名称
            if (!procedureName) {
                $.messager.alert('消息提示', '请选择存储过程!');
                return;
            }

            //存储过程参数绑定信息
            var procedureParamBindingArray = new Array();//目标实体绑定array
            var rows = $("#procedureParamBindingGrid").datagrid('getRows');
            var fflag = false;
            if (null != rows && rows.length > 0) {
                for (var i = 0; i < rows.length; i++) {
                    var row = rows[i];
                    var argument_name = row.argument_name;//过程参数名
                    var data_type = row.data_type;//过程参数类型
                    var in_out = row.in_out;//过程参数输入输出类型
                    var position = row.position;//存储过程参数位置
                    var binding_param = row.binding_param;//绑定参数列
                    var rowData = {
                        'argument_name': argument_name,
                        'binding_param': binding_param,
                        'data_type': data_type,
                        'in_out': in_out,
                        'position': position
                    };
                    if (in_out == 'IN' && $.trim(binding_param) == "") {
                        fflag = true;
                    }
                    procedureParamBindingArray.push(rowData);
                }
            } else {
                $.messager.alert('消息提示', '存储过程必须有输入参数!');
                return;
            }
            if (fflag) {
                $.messager.alert('消息提示', '存储过程输入参数必须绑定参数!');
                return;
            }
            var procedureParamBindingDataJson = arrayToJson(procedureParamBindingArray);//规则参数设置
            var procedureParamBindingJson = procedureParamBindingDataJson == "[]" ? " " : procedureParamBindingDataJson;
            var baseParamJson = {
                procedureName: procedureName,
                checkContext: checkContext,
                otType: otType,
                ruleName: ruleName,
                procedureParamBindingJson: procedureParamBindingJson,
                projID: projID,
                projectPackageID: projectPackageId
            };

            var baseParamStr = JSON.stringify(baseParamJson);
            var flag = "";
            var msg = "";
            var ruleId = "";
            if (ruleId != "" && ruleId.length > 0) {
                flag = "update";
                msg = "修改失败!";
            } else {
                flag = "save";// 默认：新增操作
                msg = "添加失败!";
            }

            $.ajax({
                type: "post",
                url: basePath + "/zj/zjProcedureManager.do?method=saveOrUpdateRule&newDate=" + (new Date()).getTime(),
                async: true,
                dataType: "json",
                success: function (responseData) {
                    var returnFlag = responseData.returnFlag;
                    var returnMessage = responseData.returnMessage;
                    if (returnFlag) {
                        $('#ruleManageWin').dialog({closed: true});
                        $("#managerTab").datagrid("reload");
                        $.messager.alert('消息提示', returnMessage);
                    } else {
                        $.messager.alert('消息提示', returnMessage);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.alert('消息提示', '请求数据失败，请检查服务器是否为开启状态!' + textStatus);
                    return false;
                },
                data: {
                    flag: flag,
                    baseParam: baseParamStr,
                    appCode: "XJYT"
                }
            });
        }

        /**
         * 打开存储过程选择窗口
         */
        function openProcedureSelWin() {
            $("#btn_procedure_cancel").unbind("click");
            $("#btn_procedure_cancel").bind("click", function () {
                $('#div_procedureWin').dialog({closed: true});
            });
            //$.initDataLinkCombobox();
            //初始Grid
            initProcedureGrid();
            document.getElementById("search_procedureName").value = "";
            $('#div_procedureWin').dialog({
                title: '存储过程选择',
                closed: false,
                buttons: '#div_procedureSelBtns'
            });
        }

        function initProcedureGrid() {
            $("#tbl_procedure").datagrid({
                height: 340,
                rownumbers: true,
                columns: dataModelColDatas,
                fitColumns: true,
                striped: true,
                nowrap: true,
                pagination: true,
                singleSelect: true,
                idField: 'entId',
                pageNumber: 1,
                pageSize: 20,
                pageList: [10, 20, 30],
                sortName: 'entCode',
                sortOrder: 'asc',
                toolbar: '#div_procedureToolbar',
                title: '',
                onDblClickRow: function (rowIndex, rowData) {
                    var selectedRows = $(this).datagrid('getSelections');
                    var flag = false;
                    for (i = 0; i < selectedRows.length; i++) {
                        if (selectedRows[i] == rowData) {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        $(this).datagrid("selectRow", rowIndex);
                    }
                    //dbClickDataModel = rowData;
//    				$("#btn_dataModelEdit").click();
                    //dataModelManageEdit();
                },
                onLoadSuccess: function (data) {
                    //$('#tbl_procedure').datagrid('clearSelections');
                },
                onSelect: function (rowIndex, rowData) {
                }
            });
            var p1 = $('#tbl_procedure').datagrid().datagrid('getPager');
            $(p1).pagination({
                pageSize: 10,//每页显示的记录条数，默认为10
                pageList: [10, 20, 30],//可以设置每页记录条数的列表
                beforePageText: '第',//页数文本框前显示的汉字
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
            });

            $("#tbl_procedure").datagrid('loadData', {total: 0, rows: []});

        };

        //数据模型管理列信息
        var dataModelColDatas = [
            [
                {
                    field: 'entName',
                    title: '实体对象中文名称',
                    width: 350
                }, {
                field: 'entType',
                title: '实体类型',
                width: 350,
                formatter: function (cellvalue, options, rowObject) {
                    if (cellvalue == 'TABLE' || cellvalue == 'table') {
                        return "表";
                    } else if (cellvalue == 'VIEW' || cellvalue == 'view') {
                        return "视图";
                    } else if (cellvalue == 'PROCEDURE' || cellvalue == 'procedure' || cellvalue == 'PACKAGE' || cellvalue == 'package') {
                        return "存储过程";
                    }
                }
            }]
        ];

        function searchProcedure() {
            var search_procedureName = document.getElementById("search_procedureName").value;
            initProceduerGrid(search_procedureName);
        }

        function initProceduerGrid(procedureName) {
            if (!procedureName) {
                procedureName = "";
            }

            var paramData = "{'procedureName':'" + procedureName + "'}";
            $("#tbl_procedure").datagrid('loadData', {total: 0, rows: []});
            $("#tbl_procedure").datagrid({
                queryParams: {paramData: paramData},
                url: basePath + "/zj/procedureInfo?procedureName=" + procedureName + "&newDate=" + (new Date()).getTime()
            });
        }

        /**
         * 存储过程选择窗口确定事件
         */
        function procedureSelectSure() {
            var rowData = $('#tbl_procedure').datagrid('getSelected');
            if (rowData) {
                //设置存储过程名称
                $('#procedureName').searchbox('setValue', rowData.entName);
                $.ajax({
                    type: "post",
                    url: basePath + "/zj/zjProcedureManager.do?method=getProcedureParameters&newDate=" + (new Date()).getTime(),
                    async: false,
                    dataType: "json",
                    success: function (responseData) {
                        $('#procedureParamBindingGrid').datagrid('loadData', responseData)
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                    },
                    data: {procedureName: rowData.entName}
                });

                $('#div_procedureWin').dialog({closed: true});
            } else {
                $.messager.alert("系统窗口", "请选择行！", "error");
            }
        }

        function arrayToJson(o) {
            var r = [];
            if (typeof o == "string")
                return "\""
                    + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n")
                        .replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\"";
            if (typeof o == "object") {
                if (!o.sort) {
                    for (var i in o)
                        if (typeof (o[i]) != "undefined" && null != o[i]) {
                            r.push(i + ":" + this.arrayToJson(o[i]));
                        } else {
                            r.push(i + ":" + "\"\"");//当key中的value未定义或null时,给value初始为""
                        }
                    if (!!document.all
                        && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/
                            .test(o.toString)) {
                        r.push("toString:" + o.toString.toString());
                    }
                    r = "{" + r.join() + "}";
                } else {
                    for (var i = 0; i < o.length; i++) {
                        r.push(this.arrayToJson(o[i]));
                    }
                    r = "[" + r.join() + "]";
                }
                return r;
            }
            return o.toString();
        }
    </script>
</head>
<body class="easyui-layout" style="width: auto; height: 550px">
<div id="loading-mask"
     style="position:absolute;top:0px; left:0px; width:100%; height:100%; background:#D2E0F2; z-index:20000">
    <div id="pageloading"
         style="position:absolute; top:50%; left:50%; margin:-120px 0px 0px -120px; text-align:center;  border:2px solid #8DB2E3; width:200px; height:40px;  font-size:14px;padding:10px; font-weight:bold; background:#fff; color:#15428B;">
        正在加载,请稍候...
    </div>
</div>
<div data-options="region:'west' " style="width: 300px">
    <ul id="treeDemo">
    </ul>
</div>
<!-- 父节点菜单 -->
<div id="pMenu1" class="easyui-menu" style="width:120px;display: none;">
    <div onClick="addProject()" data-options="iconCls:'icon-add'">新建质检项目</div>
    <div onClick="addProjectPkg()" data-options="iconCls:'icon-add'">新建质检目录</div>
    <div onClick="editProjectName()" data-options="iconCls:'icon-edit'">重命名</div>
    <div onClick="deleteProject()" data-options="iconCls:'icon-remove'">删除</div>
</div>

<!-- 父节点菜单 -->
<div id="pMenu2" class="easyui-menu" style="width:120px;display: none;">
    <div onClick="addProject()" data-options="iconCls:'icon-add'">新建质检项目</div>
    <div onClick="addProjectPkg()" data-options="iconCls:'icon-add'">新建质检目录</div>
    <div onClick="editProjectName()" data-options="iconCls:'icon-edit'">重命名</div>
</div>

<!-- 父节点菜单 -->
<div id="pMenu3" class="easyui-menu" style="width:120px;display: none;">
    <div onClick="addProjectPkg()" data-options="iconCls:'icon-add'">新建质检目录</div>
</div>
<!-- 子节点菜单 -->
<div id="lMenu" class="easyui-menu" style="width:120px;display: none;">
    <div onClick="addProject()" data-options="iconCls:'icon-edit'">修改质检项目</div>
    <div onClick="deleteProject()" data-options="iconCls:'icon-remove'">删除</div>
</div>
<div data-options="region:'center', border:false"
     style="border-color: #ccc; width: 100%; height: 100%;">
    <table id="managerTab" class="easyui-datagrid"
           style="width: auto; height: 800px" fit="true"></table>
    <div id="tb" style="height: auto">
        <a href="javascript:openAddQualityRuleWin()" class="easyui-linkbutton"
           data-options="iconCls:'icon-add',plain:true">新增规则</a>
        <a href="javascript:deleteRuleData()" class="easyui-linkbutton" id="deleteRuleData"
           data-options="iconCls:'icon-remove',plain:true ">删除</a>
    </div>
</div>
<!-- 规则定制窗口  start-->
<div id="ruleManageWin" class="easyui-dialog"
     style="height: 600px; width: 720px;"
     data-options="closed:true, modal:true">
    <div class="easyui-layout" data-options="fit:true"
         style="height: 197px; background: #efefef; margin-top: 5px;">
        <div data-options="region:'center'">
            <div title="存储过程配置" id="1" style="padding: 5px;">
                <form id="form_ruleManage_2" method="post">
                    <input type="hidden" id="planId"/> <input type="hidden"
                                                              id="procedureDbLinkId"/> <input type="hidden"
                                                                                              id="procedureId"/>
                    <input type="hidden" id="procedureParam"/> <input type="hidden"
                                                                      id="procedureSubDbLinkId"/> <input type="hidden"
                                                                                                         id="procedureDbLinkUser"/>
                    <table>
                        <tr>
                            <td style='font-weight: bold; color: #2e6e9e' align="right">
                                规则名称:
                            </td>
                            <td><input type="text" id="ruleName" style="width: 300px;"/></td>
                        </tr>
                        <tr>
                            <td style='font-weight: bold; color: #2e6e9e' align="right">
                                查询结果显示区块/机构:
                            </td>
                            <td><select id="otType" name="otType">
                                <option value=""></option>
                                <option value="1" selected="selected">机构</option>
                                <option value="2">区块</option>
                            </select>
                            </td>
                        </tr>
                        <tr>
                            <td style='font-weight: bold; color: #2e6e9e' align="right">
                                检查内容:
                            </td>
                            <td><textarea id="checkContext" rows=5 name="checkContext" style="width: 300px;"
                                          class="textarea easyui-validatebox"></textarea></td>
                        </tr>
                        <tr>
                            <td style='font-weight: bold; color: #2e6e9e' align="right">
                                存储过程:
                            </td>
                            <td><input type="text" id="procedureName"
                                       class="easyui-searchbox" style="width: 300px;"/></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table id="procedureParamBindingGrid"></table>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>

    <!-- 数据计算对象定义窗口按钮 -->
    <div id="div_FlowManage_Btns" closed="true">
        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
           style="width: auto; height: auto;" id="btn_FlowManage_sure">确定</a>
        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
           style="width: auto; height: auto;" id="btn_FlowManage_cancel">取消</a>
    </div>
</div>
<div id="div_procedureWin" class="easyui-dialog" style="width: 757px; height:420px;"
     data-options="closed:true, modal:true, left: 30, top:30">
    <div id="div_procedureToolbar" style="display: none;">
        <form id="searchForm">
            <table>
                <tr>
                    <td>
                        <label style="font-weight: bold; color: #2e6e9e; font-size: 12px">
                            存储过程：
                        </label>
                    </td>
                    <td>
                        <input id="search_procedureName"/>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="iconCls:'icon-search',plain:true" onclick="searchProcedure()">查询</a>
                        <a href="javascript:void(0);" class="easyui-linkbutton"
                           data-options="iconCls:'icon-undo',plain:true" onclick="resetProcedureSearch()">重置</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div data-options="fit:true">
        <table id="tbl_procedure" data-options="border:false"></table>
    </div>
    <div id="div_procedureSelBtns">
        <a href="javascript:void(0)" class="easyui-linkbutton" id="btn_procedure_sure" iconCls='icon-ok'
           style="width: auto; height: auto;" onclick="procedureSelectSure()">确定</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" id="btn_procedure_cancel" iconCls='icon-cancel'
           style="width: auto; height: auto;">取消</a>
    </div>
</div>
</body>
</html>